import React from 'react'; import { IUserHasId } from '@growi/core'; import { NextPage, GetServerSideProps, GetServerSidePropsContext, } from 'next'; import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import dynamic from 'next/dynamic'; import Head from 'next/head'; import CountBadge from '~/components/Common/CountBadge'; import PageListIcon from '~/components/Icons/PageListIcon'; import { ShareLinkLayout } from '~/components/Layout/ShareLinkLayout'; import GrowiContextualSubNavigation from '~/components/Navbar/GrowiContextualSubNavigation'; import { Page } from '~/components/Page'; import styles from '~/components/Page/DisplaySwitcher.module.scss'; // for PageList toc style import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript'; import TableOfContents from '~/components/TableOfContents'; import { SupportedAction, SupportedActionType } from '~/interfaces/activity'; import { CrowiRequest } from '~/interfaces/crowi-request'; import { RendererConfig } from '~/interfaces/services/renderer'; import { IShareLinkHasId } from '~/interfaces/share-link'; import { useCurrentUser, useCurrentPathname, useCurrentPageId, useRendererConfig, useIsSearchPage, useShareLinkId, useIsSearchServiceConfigured, useIsSearchServiceReachable, useIsSearchScopeChildrenAsDefault, useDrawioUri, useIsContainerFluid, } from '~/stores/context'; import { useDescendantsPageListModal } from '~/stores/modal'; import loggerFactory from '~/utils/logger'; import { CommonProps, getServerSideCommonProps, generateCustomTitle, getNextI18NextConfig, } from '../utils/commons'; const logger = loggerFactory('growi:next-page:share'); const ShareLinkAlert = dynamic(() => import('~/components/Page/ShareLinkAlert'), { ssr: false }); const ForbiddenPage = dynamic(() => import('~/components/ForbiddenPage'), { ssr: false }); type Props = CommonProps & { shareLink?: IShareLinkHasId, isExpired: boolean, disableLinkSharing: boolean, isSearchServiceConfigured: boolean, isSearchServiceReachable: boolean, isSearchScopeChildrenAsDefault: boolean, drawioUri: string | null, rendererConfig: RendererConfig, }; const SharedPage: NextPage = (props: Props) => { useIsSearchPage(false); useShareLinkId(props.shareLink?._id); useCurrentPageId(props.shareLink?.relatedPage._id); useCurrentUser(props.currentUser); useCurrentPathname(props.currentPathname); useRendererConfig(props.rendererConfig); useIsSearchServiceConfigured(props.isSearchServiceConfigured); useIsSearchServiceReachable(props.isSearchServiceReachable); useIsSearchScopeChildrenAsDefault(props.isSearchScopeChildrenAsDefault); useDrawioUri(props.drawioUri); useIsContainerFluid(props.isContainerFluid); const { open: openDescendantPageListModal } = useDescendantsPageListModal(); const { t } = useTranslation(); const isNotFound = props.shareLink == null || props.shareLink.relatedPage == null || props.shareLink.relatedPage.isEmpty; const isShowSharedPage = !props.disableLinkSharing && !isNotFound && !props.isExpired; const shareLink = props.shareLink; const title = generateCustomTitle(props, 'GROWI'); return ( <> {title}
{isShowSharedPage && }
{ props.disableLinkSharing && (
)} { (isNotFound && !props.disableLinkSharing) && (